package com.itzgyw.example.config;

import com.itzgyw.cache.analysis.ResultTypeAnalysis;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;

import java.util.List;

/**
 * @Auther: Mr. Zeng
 * @Date: 2020/8/20 16:12
 * @Description: 暂无描述
 */
public class PageableResultTypeAnalysis implements ResultTypeAnalysis<Page, List> {

    public PageableResultTypeAnalysis() {
    }


    @Override
    public List analysis(Page source) {
        return source.getContent();
    }

    @Override
    public Page merge(Page source, List data) {
        return new PageImpl(data, source.getPageable(), source.getTotalElements());
    }

    @Override
    public Class getSupportClasses() {
        return Page.class;
    }
}
